<?php $this->load->view('intro'); ?>
<body id="store_config">
<?php $this->load->view('admin/navigation'); ?>
<div id="edit_section">
<form>
<label for="store_name_input">Store Name: </label>
<input maxlength="64" id="store_name_input" type="text" value="<?php echo $store['name'] ?>" /><br/>
<label for="phone_input">Phone: </label>
<input id="phone_input" type="text" value="<?php echo $store['phone'] ?>" /><br/>
<label for="address_input">Address: </label>
<input id="address_input" type="text" value="<?php echo $store['address'] ?>" /><br/>
<label for="city_input">City: </label>
<input maxlength="64" id="city_input" type="text" value="<?php echo $store['city'] ?>" />
<label for="state_input">State: </label>
<input maxlength="32" id="state_input" type="text" value="<?php echo $store['state'] ?>" />
<label for="zipcode_input">Zipcode: </label>
<input maxlength="16" id="zipcode_input" type="text" value="<?php echo $store['zipcode'] ?>" /><br/> 
<label for="footer_textarea" >Footer Note: </label>
<textarea id="footer_textarea"><?php echo $store['footer'] ?></textarea><br/>
<label for="tax_rate">Tax Rate: </label>
<input class="double_input" id="tax_rate" type="text" value="<?php echo $store['taxrate'] ?>" />
<label class="dash" for="tax_rate">%</label>
<div id="update_store_button" class="button">Update</span></div>
</div>
<script type="text/javascript">
/**
 * javascript for admin store configuration 
 *  
 * javascript to improve navigation between all the store configuration fields
 * and use AJAX call to update information
 * 
 * @require    'jquery-1.3.2.min.js'
 * @author     Chendaping
 */
/**
 * AJAX call register to form - ? use submit register to get default form for all form
 */
$(document).ready(function(){
  $("#update_store_button").mouseup(function(){
    $data = {name:        $("#store_name_input").val(),
             phone:       $("#phone_input").val(),
             address:     $("#address_input").val(),
             city:        $("#city_input").val(),
             state:       $("#state_input").val(),
             zipcode:     $("#zipcode_input").val(),
             footer:      $("#footer_textarea").val(), 
             taxrate:     $("#tax_rate").val()
            };
    $.ajax({
      type: "POST",
      url: "index.php/admin/store_config/update",
      dataType: "json",
      data: $data,
      success: function(msg){
       alert( "Updated: " + msg.status + "\nMessage: " + msg.error);
      }
    });
  });
});

/* End of file store_config.js */
/* Location: ./javascript/admin/store_config.js */</script>
<?php $this->load->view('outro'); ?>
